<% layout('/layout/default.html', {title: '用户管理', libs: ['validate','icheck']}){ %>
<div class="main-content">
	<div class="container-fluid">
		<div class="card-header">
			<div class="box-title">
				<i class="fa fa-sitemap"></i> 用户添加
			</div>
		</div>

		<#form:form id="inputForm" model="${user}" class="form-horizontal" action="${ctx}/sys/user/save" method="post">
		<div class="card-body">
			<#form:hidden path="id"/>
			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="用户名">
							<span style="color:red;" aria-required="true">*</span> 用户名: <i class="fa icon-question hide"></i>
						</label>
						<div class="col-sm-8">
							<#form:input path="name" maxlength="50" class="form-control form-control-sm required" />
						</div>
					</div>
				</div>
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="工号">
							工号:
						</label>
						<div class="col-sm-8">
							<#form:input path="no" class="form-control form-control-sm " maxlength="50" />
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="登录名">
							<span style="color:red;" aria-required="true">*</span>登录名: <i class="fa icon-question hide"></i>
						</label>
						<div class="col-sm-8">
							<%if(!user.isNewRecord){%>
							<input id="oldLoginName" name="oldLoginName" type="hidden" value="${user.loginName}" />
							<%}%>
							<#form:input path="loginName" maxlength="50" class="form-control form-control-sm required "/>
						</div>
					</div>
				</div>
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="用户岗位">
							<span style="color:red;" aria-required="true">*</span> 用户岗位: <i class="fa icon-question hide"></i>
						</label>
						<div class="col-sm-8">
							<#form:select path="userPost" name="label" data="getDictList:sys_user_type"  class="form-control select2bs4 required" />
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="归属公司">
							<span style="color:red;" aria-required="true">*</span> 归属公司: <i class="fa icon-question hide"></i>
						</label>
						<div class="col-sm-8">
							<#form:treeselect id="companyId" name="company.id" value="${user.company.id!}" labelName="user.company.parentName"
							labelValue="${user.company.name!}" title="公司" url="/sys/office/treeData?type=1" notAllowSelectParent="true" cssClass="form-control-sm" />
						</div>
					</div>
				</div>
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="归属部门">
							<span style="color:red;" aria-required="true">*</span> 归属部门: <i class="fa icon-question hide"></i>
						</label>
						<div class="col-sm-8">
							<#form:treeselect id="officeId" name="office.id" value="${user.office.id!}" labelName="user.office.parentName"
							labelValue="${user.office.name!}" title="部门" url="/sys/office/treeData?type=2" notAllowSelectParent="true" />
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="是否允许登录">
							<span style="color:red;" aria-required="true">*</span> 是否允许登录: <i class="fa icon-question hide"></i>
						</label>
						<div class="col-sm-8">
							<#form:select path="loginFlag" name="label"  data="getDictList:yes_no" class="form-control select2bs4 required" />
						</div>
					</div>
				</div>
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="邮箱">
							邮箱:
						</label>
						<div class="col-sm-8">
							<#form:input path="email" maxlength="50" class="form-control form-control-sm email"/>
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="电话">
							电话:
						</label>
						<div class="col-sm-8">
							<#form:input path="phone" maxlength="50" class="form-control form-control-sm" />
						</div>
					</div>
				</div>
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="手机">
							手机:
						</label>
						<div class="col-sm-8">
							<#form:input path="mobile" class="form-control form-control-sm" maxlength="50" />
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="用户角色">
							用户角色:
						</label>
						<div class="col-sm-8">
							<#form:checkboxes path="roleIdList" data="${user.roleIdList}" items="${allRoles}" itemLabel="name" itemValue="id" />
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="上次登录">
							备注:
						</label>
						<div class="col-sm-8">
							<#form:textarea path="remarks" rows="3" cols="32"  class="form-control"></#form:textarea>
					</div>
				</div>
			</div>
		</div>

	</div>
	<div class="box-footer">
		<div class="row">
			<div class="offset-md-2 col-md-10">
				<% if (hasPermi('sys:user:edit')){ %>
				<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>
				<% } %>
				<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="window.parent.closeCurrentTabPage();"><i class="fa fa-reply-all"></i> 关 闭</button>
			</div>
		</div>
	</div>
</#form:form>
</div>
</div>
<% } %>
<script>
	$("#inputForm").validate({
		submitHandler: function(form){
			js.ajaxSubmitForm($(form), function(data){
				js.showMessage(data.message);
				if(data.result == 'true'){
					window.parent.closeCurrentTabPage(window.parent.refreshTab);
				}
			});
		}
	});
</script>